import CommonAPI from "@/api/system/common";

// 查询参数
export interface queryParams {
    page: number;
    limit: number;
    total: number;
}

// 查询参数
export interface btnObj {
    name: string;
    iconName: string;
    perms: string;
    isPlain: boolean;
}

// 查询参数
export interface reset {
    reset: boolean;
}

// 工具列表
export const btnList: Array<btnObj> = [
    {
        name: "新增用户组",
        iconName: "plus",
        perms: "sys:user:addUser",
        isPlain: false,
    },
];

export const tableHead = reactive([
    {
        prop: "id",
        label: "ID",
    },

    {
        prop: "name",
        label: "用户组名称",
    },
    {
        prop: "create_username",
        label: "创建人",
    },
    {
        prop: "create_phone",
        label: "手机号",
    },
    {
        prop: "user_total",
        label: "组员数量",
    },

    {
        prop: "status",
        label: "状态",
    },

    {
        prop: "create_time",
        label: "创建时间",
    },
    {
        prop: "",
        label: "操作",
        width: "300",
        align: "center",
    },
]);
export const toDoRow = reactive([
    {
        name: "查看",
        icon: "View",
    },
    {
        name: "编辑",
        icon: "edit",
    },
    {
        name: "添加成员",
        icon: "plus",
    },
]);

// 添加用户组表单验证规则
export const addUserGroupFromRules = reactive({
    name: [{ required: true, message: "请输入用户组名称", trigger: "blur" }],
    describe: [
        { required: true, message: "请输入用户组描述", trigger: "blur" },
    ],
});

// 用户组状态
export const userGroupStatusOption = ref([
    {
        label: "禁用",
        value: 0,
    },
    {
        label: "正常",
        value: 1,
    },
]);

export const baseInfoMap = [
    {
        label: "用户组名称",
        key: "name",
        width: "100%",
    },
    {
        label: "用户组描述",
        key: "describe",
        width: "100%",
    },
    // {
    //     label: "单位介绍",
    //     key: "realname",
    //     width: "100%",
    // },
];

const createdInMap = [
    {
        label: "创建时间",
        key: "create_time",
    },
    {
        label: "创建人",
        key: "create_username",
    },
    {
        label: "最近修改时间",
        key: "update_time",
    },
];

const infoMap = new Map([
    ["用户组信息", baseInfoMap],
    ["用户组成员", []],
    ["权限信息", []],
    ["创建信息", createdInMap],
]);

export const formTitleList = Array.from(infoMap.keys());

export const getInfoList = (
    data: any,
    nameSting: "用户组信息" | "创建信息"
) => {
    let keyList = infoMap.get(nameSting);
    return keyList!.map((item: any) => {
        return {
            label: item.label,
            value: data[item.key],
            width: item.width,
        };
    });
};
